<?php
namespace app\service;
use think\facade\Db;
class ufaceService{
	//小区列表
    public function communityList()
    {
        $list = Db::name('community')->select();
        return $list;
    }
    //组团列表
    public function groupList($community_id)
    {
        $list = Db::name('room')->distinct('group')->where('community',$community_id)->column('group');
        
        return $list;
    }
    //幢数列表
    public function buildingList($group,$community_id)
    {
        $list = Db::name('room')->distinct('building')->where('group',$group)->where('community',$community_id)->order('building')->column('building');
        return $list;
    }
    //单元列表
    public function unitList($building,$group,$community_id)
    {
        $list = Db::name('room')->distinct('unit')->where('community',$community_id)->where('group',$group)->where('building',$building)->column('unit');
        $list = array_unique($list);

        return $list;
    }
    //房屋列表
    public function roomList($unit,$building,$group,$community_id)
    {
        $list = Db::name('room')->where('community',$community_id)->where('group',$group)->where('unit',$unit)->where('building',$building)->column('room');
        $list = array_unique($list);
        return $list;
    }

    public function getroominfo($community_id,$group,$building,$unit,$room){
        return Db::name("room")
                    ->where("community",$community_id)
                    ->where("group",$group)
                    ->where("building",$building)
                    ->where("unit",$unit)
                    ->where("room",$room)
                    ->find();
    }
}